package com.first.agent.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.first.agent.common.R;
import com.first.agent.pojo.Role;
import com.first.agent.service.RoleService;
import com.first.agent.service.impl.RoleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
/*
角色管理——修改
 */
@WebServlet("/role/mod")
public class ModRoleServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String role_name = request.getParameter("role_name");
        String status = request.getParameter("status");
        String role_id = request.getParameter("role_id");
        RoleService roleService = new RoleServiceImpl();
        R r = roleService.roleMod(role_name, Integer.parseInt(status), role_id);
        response.setContentType("application/json;charset=utf-8");
        PrintWriter pw = response.getWriter();
        pw.write(JSONObject.toJSONString(r));
        pw.flush();
        pw.close();
    }
}
